#!/usr/local/bin/perl use URI::Escape; print "Content-type: text/html\n\n"; #images.record will hold the images, archives, and other .html and .htm files sub candelete { my $filename = $_[0]; my $verified = '0'; open(USRDEL, "<../checks/files.record"); flock(USRDEL, 1); while() { if($_ =~ /^$filename/) { chomp; $verified= $filename; #print"file exists for deleting = ".$filename; #print"
"; next; } } close(USRDEL); return $verified; } # end candelete(); sub rewrite { my $filename = $_[0]; #print"file name can be rewritten = ".$filename; #print"
"; my $deleted = 0; open(USRTEMP, ">>../checks/files.temp"); open(USRDEL, "<../checks/files.record"); flock(USRTEMP, 2); flock(USRDEL, 2); while() { if($_ =~ /^$filename/) { #print"match = ".$filename; #print"
"; $deleted = $filename; next; } print USRTEMP "$_"; } close(USRTEMP); close(USRDEL); #return the filename if it exists, else returns 0 for failure return $deleted; }#end sub rewrite sub renamerecord { rename("../checks/files.record", "../checks/files.last"); rename("../checks/files.temp", "../checks/files.record"); }#end sub renamerecord #decode the URL since it was encoded in the view shown on the images page my $filename =uri_unescape($ENV{'QUERY_STRING'}); my $candelete = candelete($filename); #print"about to delete = ".$candelete; if($filename eq $candelete) { #the file can be deleted rewrite($filename); renamerecord(); unlink($filename); #print "file deleted = ".$filename; #print "
"; if($filename =~ /^archive/) { print ""; print "If your browser does not support META refresh. Return to Survey Administration page"; } else { print ""; print "If your browser does not support META refresh.Return to Survey Administration page"; } } else { #file not found if($filename =~ /^archive/) { print ""; print "If your browser does not support META refresh.Return to Survey Administration page"; } else { print ""; print "If Your browser does not support META refresh.Return to Survey Administration page"; } }